<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>作用域-let-const不挂载到window</title>
</head>
<body>
  
  <script>
    // 1. var 声明的变量会挂载到window上
    var c = 30;
    console.log(window.c); // 30
    
    // 2. let const 声明的变量不会挂载到window上
    let a = 10;
    console.log(window.a); // undefined

    const b = 20;
    console.log(window.b); // undefined

    // 3. let const 声明的变量
    let message = 'hello';
    const name = 'jack';

    function foo() {
      debugger
    }

    foo();
    
  </script>
  
</body>
</html>